package com.zjsystem.zjsy.controller;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zjsystem.zjsy.constant.Constant;
import com.zjsystem.zjsy.dto.ZjPlanLog;
import com.zjsystem.zjsy.dto.ZjZt;
import com.zjsystem.zjsy.result.Result;
import com.zjsystem.zjsy.service.ZjPlanLogService;
import com.zjsystem.zjsy.service.ZjZtService;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 战机主表 首页：代办事项列表
 * </p>
 *
 * @author wyf
 * @since 2024-06-20
 */
@Slf4j
@RestController
@RequestMapping("/zjsy/zjzt")
public class ZjZtController {

    @Resource
    private ZjZtService ztService;
    @Resource
    private ZjPlanLogService planLogService;

    @ApiModelProperty("代办事项列表 分页展示")
    @GetMapping("zjPage/list")
    public Result ZjPage() {
        try {
            Page<ZjZt> page = ztService.page(new Page<>(1, 10),
                    Wrappers.<ZjZt>lambdaQuery().eq(ZjZt::getLjsc, Constant.zero));
            return Result.ok(page.getRecords());
        } catch (Exception e) {
            log.error(e.getMessage());
            return Result.fail(e.getMessage());
        }
    }

    @ApiModelProperty("告警 分页展示")
    @GetMapping("gjPage/list")
    public Result GjPage() {
        try {
            List<ZjPlanLog> list = planLogService.list(Wrappers.<ZjPlanLog>lambdaQuery()
                    .eq(ZjPlanLog::getIsPast, Constant.one));
            return Result.ok(list);
        } catch (Exception e) {
            log.error(e.getMessage());
            return Result.fail(e.getMessage());
        }
    }
}

